package com.qiongqi.datadir.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.Instant;
import java.util.List;

/**
 * 数据使用合约
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class DataUsageContract extends BaseDomain{
    private String contractId;
    private String version;
    private Parties parties;
    private String purpose;
    private String purposeCode;
    private List<DataSet> dataSets;
    private List<Permission> permissions;
    private List<Prohibition> prohibitions;
    private List<Obligation> obligations;
    private Instant startDate;
    private Instant endDate;
    private String status;
    private List<String> compliances;

    @Data
    public static class Parties {
        private List<String> dataController;
        private String dataProcessor;
        private String platform;
    }

    @Data
    public static class DataSet {
        private String provider;
        private String resource;
        private List<String> fields;
        private List<String> usage;
    }

    @Data
    public static class Permission {
        private String action;
        private Constraint constraint;
    }

    @Data
    public static class Constraint {
        private String purpose;
        private String time;
    }

    @Data
    public static class Prohibition {
        private String action;
        private String target;
        private String reason;
    }

    @Data
    public static class Obligation {
        private String action;
        private String description;
    }
}